package com.gxa.worker.recycling.controller;

import com.gxa.core.recycling.anno.NeedToken;
import com.gxa.core.recycling.common.JsonResult;
import com.gxa.core.recycling.exception.BusinessException;
import com.gxa.core.recycling.pojo.CommunityManage;
import com.gxa.core.recycling.pojo.Waste;
import com.gxa.worker.recycling.service.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ：looker
 * @date ：Created in 2021/12/8 12:26
 */
@CrossOrigin
@RestController
@RequestMapping("/community")
@Api("小区管理接口")
public class CommunityController {
    @Autowired
    CommunityService communityService;

    @NeedToken
    @PostMapping("/getByPosition")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "position", value = "位置", required = true, dataType = "string"),
    })
    @ApiOperation("查询指定省市区的小区信息")
    public Map getWasteInfo(String position) throws BusinessException {

        List<CommunityManage> likePosition = communityService.getLikePosition(position);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(likePosition);
        return jsonResult.getDataMap();
    }

}
